package mvc.gui.impl.toolpanel;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Iterator;
import java.util.List;

import mvc.core.IMachuPicchu;
import mvc.effects.IEffect;
import mvc.gui.impl.EffectsButton;

class ToolPanelPresenter implements PropertyChangeListener {
	private IMachuPicchu machu;
	private ToolPanel panel;

	public ToolPanelPresenter(IMachuPicchu machuPicchu, ToolPanel toolpanel) {
		this.machu = machuPicchu;
		this.panel = toolpanel;
		machu.addPropertyChangeListener(this);
		addEffects();
		addEffectslist();

	}

	/*
	 * performs task to import images.
	 */
	public void importPressed() {
		machu.importImages();

	}

	/*
	 * performs task to export images.
	 */
	public void exportPressed() {
		machu.exportImages();

	}

	/*
	 * adds the available effects to the toolPanel.
	 */
	public void addEffects() {

		List<IEffect> listWithEffects = machu.getListWithEffects();
		Iterator<IEffect> it = listWithEffects.iterator();
		EffectsButton b;

		while (it.hasNext()) {

			b = new EffectsButton(machu, it.next());

			panel.jPanel1.add(b);
		}
		panel.validate();

	}

	/*
	 * Adds the effectList linked to the image displayed on mainStage.
	 */
	// TODO implement
	public void addEffectslist() {

		String[] data = { "HDR", "B&W", "Flip", "Sepia" };
		panel.jList1.setListData(data);
		panel.validate();

	}

	/*
	 * Will listen to Model. Make changes to effectslist linked to image
	 * displayed on mainStage. (non-Javadoc)
	 * 
	 * @seejava.beans.PropertyChangeListener#propertyChange(java.beans.
	 * PropertyChangeEvent)
	 */
	@Override
	public void propertyChange(PropertyChangeEvent evt) {
		// TODO Auto-generated method stub

	}

}
